      subroutine hrucommandSQLite(hru_id,period,all_result,part_result)

      use parm

      integer, intent(in) :: hru_id
      real, intent(in), dimension(mhruo) :: all_result
      real, intent(in), dimension(mhruo) :: part_result
      integer, intent(in) :: period !!maybe day,month,year
      integer :: j
      character (len=10) :: sqlitedata

      j = hru_id

      !!generate the insert sql for one hru result to save in SQLite
      !!Zhiqiang, 2012-9-25
       command = hruinsert

       !!hru id
       write(sqlitedata,"(i10)") j
       command = command(:len_trim(command)) //sqlitedata

       !!subbasin number
       write(sqlitedata,"(i10)") hru_sub(j)
       command = command(:len_trim(command)) // ',' // sqlitedata

       !!current day of simulation
       write(sqlitedata,"(i10)") period
       command = command(:len_trim(command)) // ',' // sqlitedata

       do ii = 1, itots
          write(sqlitedata,"(e10.3)") part_result(ii)
          command = command(:len_trim(command)) // ',' // sqlitedata
       end do

       !!PP = ORGP + SEDP
       write(sqlitedata,"(e10.3)") part_result(12) + part_result(15)
       command = command(:len_trim(command)) // ',' // sqlitedata

       !!TDN = NSURQ + LATNO3 + GWNO3
       write(sqlitedata,"(e10.3)")
     &   part_result(13) + part_result(17) + part_result(18)
       command = command(:len_trim(command)) // ',' // sqlitedata

       !!TP = ORGP + SOLP + SEDP
       write(sqlitedata,"(e10.3)")
     &   part_result(12) + part_result(14) + part_result(15)
       command = command(:len_trim(command)) // ',' // sqlitedata

       !!TN = ORGN + NSURQ + LATNO3 + GWNO3
       write(sqlitedata,"(e10.3)")
     &   part_result(13) + part_result(17) + part_result(18)
     &   + part_result(11)
       command = command(:len_trim(command)) // ',' // sqlitedata

      command = command(:len_trim(command)) // ');'

!       if(output_test_information) then
!          write(2011,*) command
!       end if

      call sql_do(sqliteHandle,command_overlay)

      end
